import time
import xlrd
from selenium.webdriver.common.by import By
from xlutils.copy import copy

import DBUtils
from selenium import webdriver


class Test_licai:
    book = copy(xlrd.open_workbook(filename="a.xls", encoding_override=True))
    time = time.strftime('%y年%m月%d日%H:%M:%S')

    def test_lingqian_success001(self):  # 零钱理财买入成功

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击零钱理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[1]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]

        element07.send_keys("666666")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        # 再次点击确认
        element09 = driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button')
        element09.click()
        time.sleep(1)


        sql = "select balance from bankcard where userID=1 and defaultl=1"
        if DBUtils.select(sql, [])[0][0] == 99900.00:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert DBUtils.select(sql, [])[0][0] == 99900.00



    def test_lingqian_failed001(self):  # 零钱理财买入失败 支付密码错误

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击零钱理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[1]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//*[@id="password"]')[1]
        element07.send_keys("6666669")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//*[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        # 再次点击确认
        element09 = driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button')
        element09.click()
        time.sleep(1)


        sql = "select balance from bankcard where userID=1 and defaultl=1"
        if DBUtils.select(sql, [])[0][0] == 9900.00:
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert DBUtils.select(sql, [])[0][0] == 9900.00

    def test_lingqian_failed002(self):  # 零钱理财买入失败 余额不足

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi4")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击零钱理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[1]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//*[@id="password"]')[1]
        element07.send_keys("123456")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//*[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        # 再次点击确认
        element09 = driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button')
        element09.click()
        time.sleep(1)

        sql = "select balance from bankcard where userID=11 and defaultl=1"
        if DBUtils.select(sql, [])[0][0] == 9.00:
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert DBUtils.select(sql, [])[0][0] == 9.00

    def test_lingqian_failed003(self):  # 零钱理财买入失败 请绑定银行卡

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi5")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击零钱理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[1]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr['
                                                  '1]/td[6]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//*[@id="password"]')[1]
        element07.send_keys("123456")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//*[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        # 获取文本
        element09 = driver.find_element(By.XPATH, '//div[@class="jconfirm-content"]/div').text
        if element09 == "买入失败!，请绑定银行卡":

            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert element09 == "买入失败!，请绑定银行卡"


    def test_qixian_success001(self):  # 期限理财买入成功

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击期限理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[2]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]

        element07.send_keys("666666")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        # 再次点击确认
        element09 = driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button')
        element09.click()
        time.sleep(1)


        sql = "select balance from bankcard where userID=1 and defaultl=1"
        if DBUtils.select(sql, [])[0][0] == 94900.00:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert DBUtils.select(sql, [])[0][0] == 94900.00

    def test_qixian_failed001(self):  # 期限理财买入失败 支付密码错误

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击期限理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[2]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH,
                                        '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]

        element07.send_keys("6666669")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        # 再次点击确认
        element09 = driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button')
        element09.click()
        time.sleep(1)

        sql = "select balance from bankcard where userID=1 and defaultl=1"
        if DBUtils.select(sql, [])[0][0] == 89900.00:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert DBUtils.select(sql, [])[0][0] == 89900.00


    def test_qixian_failed002(self):  # 期限理财买入失败 余额不足

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi4")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击期限理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[2]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH,
                                        '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]

        element07.send_keys("123456")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)

        element09 = driver.find_element(By.XPATH, '//div[@class="jconfirm-content"]/div').text




        if element09 == "买入失败!，银行卡余额不足":
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert element09 == "买入失败!，银行卡余额不足"

    def test_qixian_failed003(self):  # 期限理财买入失败 未绑定银行卡

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi5")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击期限理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[2]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH,
                                        '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]

        element07.send_keys("123456")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        #
        element09 = driver.find_element(By.XPATH, '//div[@class="jconfirm-content"]/div').text




        if element09 == "买入失败!，请绑定银行卡":
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert element09 == "买入失败!，请绑定银行卡"


    def test_jijin_success001(self):  # 基金理财买入成功

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击基金理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[3]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]
        element07.send_keys("666666")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        # 再次点击确认
        element09 = driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button')
        element09.click()
        time.sleep(1)


        sql = "select balance from bankcard where userID=1 and defaultl=1"
        if DBUtils.select(sql, [])[0][0] == 86000.00:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert DBUtils.select(sql, [])[0][0] == 86000.00


    def test_jijin_failed001(self):  # 基金理财买入失败 密码错误

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击基金理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[3]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]
        element07.send_keys("6666669")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        # 再次点击确认
        element09 = driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button')
        element09.click()
        time.sleep(1)


        sql = "select balance from bankcard where userID=1 and defaultl=1"
        if DBUtils.select(sql, [])[0][0] == 86000.00:
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert DBUtils.select(sql, [])[0][0] == 86000.00

    def test_jijin_failed002(self):  # 基金理财买入失败 余额不足

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi4")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击基金理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[3]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]
        element07.send_keys("123456")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)

        element09 = driver.find_element(By.XPATH, '//div[@class="jconfirm-content"]/div').text

        if element09 == "买入失败!，银行卡余额不足":
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert element09 == "买入失败!，银行卡余额不足"



    def test_jijin_failed03(self):  # 基金理财买入失败 未绑定银行卡

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi5")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击基金理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[3]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]
        element07.send_keys("123456")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        #
        element09 = driver.find_element(By.XPATH, '//div[@class="jconfirm-content"]/div').text
        if element09 == "买入失败!，请绑定银行卡":
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert element09 == "买入失败!，请绑定银行卡"

    def test_zhifu_failed001(self):  # 银行卡支付测试 未设置支付密码

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi6")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击基金理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[3]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]
        element07.send_keys("123456")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        #
        element09 = driver.find_element(By.XPATH, '//div[@class="jconfirm-content"]/div').text
        if element09 == "买入失败!,请前往个人信息设置支付密码":
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert element09 == "买入失败!,请前往个人信息设置支付密码"

    def test_zhifu_failed002(self):  # 未设置绑定银行卡

        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.get("http://localhost:90")
        element01 = driver.find_element(By.XPATH,
                                        '//input[@type="text" and @placeholder="请输入您的用户名" and @class="form-control"]')
        element01.send_keys("lisi8")
        element02 = driver.find_element(By.XPATH, '//input[@type="password" and @placeholder="请输入密码" ]')
        element02.send_keys("123456")
        # 点击登录
        element03 = driver.find_element(By.XPATH, '//button[@id="login_btn" and @class="btn btn-block btn-primary"]')
        element03.click()
        # 点击个人理财
        element04 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        element04.click()
        time.sleep(1)
        # 点击基金理财
        element05 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[3]/a')
        element05.click()
        time.sleep(1)
        # 点击投资
        element06 = driver.find_element(By.XPATH, '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button')
        element06.click()
        time.sleep(1)
        # 输入支付密码
        element07 = driver.find_elements(By.XPATH, '//input[@id="password"]')[1]
        element07.send_keys("123456")
        time.sleep(1)
        # 点击确认
        element08 = driver.find_element(By.XPATH, '//div[@id="layui-layer1"]/div[3]/a[1]')
        element08.click()
        time.sleep(1)
        #
        element09 = driver.find_element(By.XPATH, '//div[@class="jconfirm-content"]/div').text
        if element09 == "买入失败!，请绑定银行卡":
            print("买入失败")
            # self.book.get_sheet(4).write(3, 6, "passed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        else:
            print("买入成功")
            # self.book.get_sheet(4).write(3, 6, "failed")
            # self.book.get_sheet(4).write(3, 7, "晏凯旋")
            # self.book.get_sheet(4).write(3, 8, self.time)
            # self.book.save("b.xls")
        driver.quit()
        assert element09 == "买入失败!，请绑定银行卡"



